from GomokuTestBase import GomokuTestBase

class IllegalPlayTest(GomokuTestBase):
    def run(self):
        """Run the illegal play test."""
        moves_first = [(2, 7), (2, 7), (2, 6), (2, 7), (2, 8)]
        moves_second = [(3, 4), (4, 4), (5, 4), (6, 4), (7, 4)]

        # Login both players
        self.login(self.firefox_driver, self.PLAYER1_CREDENTIALS)
        self.login(self.edge_driver, self.PLAYER2_CREDENTIALS)

        # Start match
        self.start_match()

        # Play moves with alert handling
        if self.is_player_turn(self.firefox_driver):
            self.play_chess_sequence(self.firefox_driver, self.edge_driver, moves_first, moves_second, handle_alert=True)
        elif self.is_player_turn(self.edge_driver):
            self.play_chess_sequence(self.edge_driver, self.firefox_driver, moves_second, moves_first, handle_alert=True)

        self.cleanup()

if __name__ == "__main__":
    test = IllegalPlayTest()
    test.run()